package com.fengziyu.lib_recyclerview_fzy.login

import android.util.Log
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.fengziyu.lib_recyclerview_fzy.entity.LoginResponse
import com.fengziyu.lib_recyclerview_fzy.mvvm.BaseViewModel

class LoginViewModel: BaseViewModel() {
    private val userRepository = UserRepository()
    private val _loginResponse = MutableLiveData<LoginResponse>()
    val loginResponse: LiveData<LoginResponse> = _loginResponse

    fun login(num: String, pwd: String) {
        Log.d("LoginViewModel", "开始登录请求")
        userRepository.login(num, pwd).observeForever { response ->
            Log.d("LoginViewModel", "收到登录响应: $response")
            _loginResponse.value = response
        }
    }
}